var util = require('../../utils/util.js');
var app = getApp();
// var noMore=false,
//     isLoading=false,
//     page=1,
//     limit=20;
Page({
  data: {
      uid:0,
      messages:[]
  },
  loadMore:function(){
      // if(!noMore && !isLoading){
      //   isLoading = true;
      //   page ++;
      //   this.load();
      // }
  },
  onLoad: function(data){
    var uid = data.uid || "";
    this.setData({
      uid:uid
    });
    this.load();
  },
  load:function(){
    var that = this;
    util.api({
      data: {
          "uid": this.data.uid,
          "publickey": util.publiccode,
          "ac": "msgcenter"
      },
      success: function(responseData){
        var data;
        if(!responseData.data.msg){
          data = responseData.data;
          var date,year,month,day;
          for(var i=0 ; i<data.length ; i++){
            date = new Date(data[i].dateline*1000);
            year = date.getFullYear();
            month = date.getMonth()+1;
            day = date.getDate();
            month = ((month+"").length == 1)?"0"+month:month;
            day = ((day+"").length == 1)?"0"+day:day;
            data[i].reTime = year + "-" + month + "-" + day;
          }
          that.setData({
            messages: data
          });
        }
        // isLoading = false;
        // var data = that.data.messages;
        // if(responseData.data.msg){
        //   noMore = true;
        // }else{
        //   data = data.concat(responseData.data.message);
        //   that.setData({
        //     sysmsg: responseData.data.sysmsg,
        //     messages: data
        //   });
        // }
      }
    });
  }
})